package com.sky.controller.user;

import com.sky.entity.Dish;
import com.sky.result.Result;
import com.sky.service.DishService;
import com.sky.service.UserDishService;
import com.sky.vo.DishVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CachePut;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController("userDishController")
@Slf4j
@RequestMapping("/user/dish")
public class UserDishController {

    @Autowired
    private UserDishService userDishService;

    // 根据分类id查询菜品
    @GetMapping("/list")
    @CachePut(value = "dishCache",key = "#categoryId")
    public Result selectByType(Integer categoryId){
        log.info("用户根据分类id查询菜品,接收到的参数是{}",categoryId);

        List<DishVO> dishes = userDishService.selectByCategoryId(categoryId);
        return Result.success(dishes);
    }




}
